package SoftwarePrinciple.DependencyInversionPrinciple;

/**
 * @author: Themberfue
 * @date: 2025/8/7 11:54
 * @description:
 */
// 高层模块 - 通知服务
public class Notification {
    // 依赖于抽象接口，而非具体实现
    private MessageService messageService;

    // 通过构造函数注入依赖
    public Notification(MessageService messageService) {
        this.messageService = messageService;
    }

    public void notifyUser(String message, String user) {
        // 调用抽象方法，不关心具体实现
        messageService.sendMessage(message, user);
    }
}

